package analysis.bean;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.Objects;

public class KPIDemension extends Unit{
    public int id;
    public String KPIName;

    public KPIDemension() {
    }

    public KPIDemension(String KPIName) {
        this.KPIName = KPIName;
    }

    public KPIDemension(int id, String KPIName) {
        this.id = id;
        this.KPIName = KPIName;
    }

    @Override
    public int compareTo(Unit o) {
        KPIDemension other = (KPIDemension) o;
        if (this.id != other.id) {
            return this.id - other.id;
        } else {
            if(!this.KPIName.equals(other.KPIName))
                return this.KPIName.compareTo(other.KPIName);
        }
        return 0;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(this.id);
        dataOutput.writeUTF(this.KPIName);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.id=dataInput.readInt();
        this.KPIName=dataInput.readUTF();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        KPIDemension that = (KPIDemension) o;
        return id == that.id &&
                Objects.equals(KPIName, that.KPIName);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, KPIName);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getKPIName() {
        return KPIName;
    }

    public void setKPIName(String KPIName) {
        this.KPIName = KPIName;
    }
}
